<?php
require_once("vcl/vcl.inc.php");
require_once("lib/validate.php");
//Includes
use_unit("components4phpfull/jtjavascript.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class validate_form extends Page
{
       public $JSValidate = null;
       public $Button1 = null;
       public $hfError = null;
       public $btnSubmit = null;
       public $editPassword = null;
       public $lblPassword = null;
       public $lblUsername = null;
       public $editUsername = null;
       function validateRequired2($value,$lbl)
       {
        if($value=='' || $value==null)
        {
         $this->$lbl->Caption = '&darr This field is required &darr';
         $this->hfError->setValue('1');
        }
       }
       function Button1JSClick($sender, $params)
       {

       ?>
       alert(document.getElementById('hfError').value);
       <?php

       }

       function editPasswordJSBlur($sender, $params)
       {

       ?>
       validateRequire('editPassword','lblPassword');
       <?php

       }


       function validate_formCreate($sender, $params)
       {
       $this->hfError->setValue('0');
       }

       function btnSubmitClick($sender, $params)
       {
        $this->validateRequired2($this->editUsername->Text,'lblUsername');
        $this->validateRequired2($this->editPassword->Text,'lblPassword');
        $error = $this->hfError->getValue();
        if($error=='1')
        {
         $this->hfError->setValue('0');
         return false;
        }
        else if($error==0)
        {
         redirect('main.php');
        }
       }



       function editUsernameJSBlur($sender, $params)
       {

       ?>
       validateRequire('editUsername','lblUsername');
       <?php

       }

}

global $application;

global $validate_form;

//Creates the form
$validate_form=new validate_form($application);

//Read from resource file
$validate_form->loadResource(__FILE__);

//Shows the form
$validate_form->show();

?>